﻿using System.Collections.Generic;
using CH.FourBoards.LagerWalti.Persistence.DataAccess;
using CH.FourBoards.LagerWalti.Persistence.Entities;

namespace CH.FourBoards.LagerWalti.Business.Core
{
    public class ProductManager
    {
        public void AddProduct(Product product)
        {
            using (var pm = new PersistenceManager()) {
                pm.Insert(product);
            }
        }

        public IEnumerable<Product> ListProducts()
        {
            using (var pm = new PersistenceManager()) {
                return pm.SelectAll<Product>(true);
            }
        }

        public void AddCategory(Category category)
        {
            using (var pm = new PersistenceManager()) {
                pm.Insert(category);
            }
        }

        public IEnumerable<Category> ListCategories()
        {
            using (var pm = new PersistenceManager()) {
                return pm.SelectAll<Category>(true);
            }
        }
    }
}
